package com.seal.commons.infrastructure.facade.distributed.limiter;

import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

/**
 * 功能描述:DistributeLimiter <br/>
 *
 * @author yong.huang
 * @date: 2020-07-24 14:19<br/>
 * @since JDK 1.8
 */
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface DistributeLimiter {

    String prefix() default "default_limiter";

    LimitKeyType limitKeyType() default LimitKeyType.CUSTOM;

    String key() default "";

    /**
     * 给定的时间范围(单位：秒)
     * @return
     */
    long period() default 1;


    TimeUnit timeUnit() default TimeUnit.SECONDS;

    /**
     * 限制次数
     * @return
     */
    long rate() default  Integer.MAX_VALUE;

    /**
     * 是否集群
     * @return
     */
    boolean isCluster() default true;


}

